package io.renren.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.ClbxDetEntity;
import io.renren.service.ClbxDetService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 差旅报销明细
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-07-30 20:49:24
 */
@RestController
@RequestMapping("clbxdet")
public class ClbxDetController {
	@Autowired
	private ClbxDetService clbxDetService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ClbxDetEntity> clbxDetList = clbxDetService.queryList(query);
		int total = clbxDetService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(clbxDetList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{bxdetId}")
	public R info(@PathVariable("bxdetId") Integer bxdetId){
		ClbxDetEntity clbxDet = clbxDetService.queryObject(bxdetId);
		
		return R.ok().put("clbxDet", clbxDet);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody ClbxDetEntity clbxDet){
		clbxDetService.save(clbxDet);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	public R update(@RequestBody ClbxDetEntity clbxDet){
		clbxDetService.update(clbxDet);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody Integer[] bxdetIds){
		clbxDetService.deleteBatch(bxdetIds);
		
		return R.ok();
	}
	
}
